package br.edu.univas.si.engs.view;

import java.awt.BorderLayout;
import java.awt.Frame;
import java.util.ArrayList;

import javax.swing.JDialog;

import br.edu.univas.si.engs.controller.Controller;
import br.edu.univas.si.engs.model.ClientTO;





public class FrameConsultarClienteReserva extends JDialog {
	
	
	



		
		

		
		
		/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
		
		private PanelConsultarClienteReserva panelConsultarClientesReserva;
		private Controller controller;
		private ClientTO clienteto;

		

		public FrameConsultarClienteReserva(String cliente, Frame object, String string, boolean b){
			super( object,string,b);
			setTitle("Consultar Cliente");
			inititialize();
			
			//setLocationRelativeTo(null); 
			//setDefaultCloseOperation(DISPOSE_ON_CLOSE);
			setLocation(290, 130);
			//setModal(true);
			pack();
			
			
		}
		
		private void inititialize() {
			
				add(getPanelConsultarClientesReserva(),BorderLayout.SOUTH);
				
					
				}
		

		public Controller getController() {
			if(controller==null){
			
				
				controller= new Controller(null, null, null, null	, null);
			}
			return controller;
		}






		public ClientTO getClienteto() {
			if(clienteto==null){
				clienteto = new ClientTO();
			}
			return clienteto;
		}













		private PanelConsultarClienteReserva getPanelConsultarClientesReserva() {
			if(panelConsultarClientesReserva==null){
				panelConsultarClientesReserva=new PanelConsultarClienteReserva();
	            panelConsultarClientesReserva.setButtonListenerConsultaclienteReserva(new ButtonListenerConsultarClienteReserv() {
					
				
					
				
					
					@Override
					public void limparAcition() {
						panelConsultarClientesReserva.limparTable();
						panelConsultarClientesReserva.getNomeFiled().setText(null);
						
					}
					
					@Override
					public void consultarAction() {
					
						ClientTO cliente = getPanelConsultarClientesReserva().getcontactClienteTo();
				        ArrayList<ClientTO> listcliente = new ArrayList<ClientTO>();
						listcliente=getController().consultarCliente(cliente.getNome());
						panelConsultarClientesReserva.limparTable();
					    getPanelConsultarClientesReserva().addContact(listcliente);
						
					}
				});
			}
			return panelConsultarClientesReserva;
		}
		


	

	
	

}
